package org.javatribe.calculator.module.view;

import org.javatribe.calculator.common.BaseFrame;
import org.javatribe.calculator.module.handler.LogHandler;

import java.awt.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import javax.swing.*;

/**
 * Created by Wenxin on 2017/9/16.
 */
public class IndexFrame extends BaseFrame {

    private final JButton ZERO_BUTTON = new JButton("0");
    private final JButton ONE_BUTTON = new JButton("1");
    private final JButton TWO_BUTTON = new JButton("2");
    private final JButton THREE_BUTTON = new JButton("3");
    private final JButton FOUR_BUTTON = new JButton("4");
    private final JButton FIVE_BUTTON = new JButton("5");
    private final JButton SIX_BUTTON = new JButton("6");
    private final JButton SEVEN_BUTTON = new JButton("7");
    private final JButton EIGHT_BUTTON = new JButton("8");
    private final JButton NINE_BUTTON = new JButton("9");
    private final JButton LEFT_BRACKETS_BUTTON = new JButton("(");
    private final JButton RIGHT_BRACKETS_BUTTON = new JButton(")");

    private final JButton PLUS_BUTTON = new JButton("+");
    private final JButton MINUS_BUTTON = new JButton("-");
    private final JButton MULTIPLY_BUTTON = new JButton("*");
    private final JButton DIVIDE_BUTTON = new JButton("/");
    private final JButton EQUAL_BUTTON = new JButton("=");

    private final JButton CLEAR_BUTTON = new JButton("C");
    private final JButton DOT_BUTTON = new JButton(".");

    private final JButton OFF_BUTTON = new JButton("OFF");

    private final JTextField TEXT_FIELD = new JTextField();


    @Override
    protected void init() {
        super.init();

        JPanel contentPanel = new JPanel(new BorderLayout());

        TEXT_FIELD.setEditable(false);
        Font textFildFont = new Font("微软雅黑", Font.BOLD, 20);
        TEXT_FIELD.setFont(textFildFont);
        TEXT_FIELD.setText("0");
        contentPanel.add(TEXT_FIELD,BorderLayout.NORTH);

        JPanel buttonPanel = new JPanel(new GridLayout(5,4,20,10));

        buttonPanel.add(ONE_BUTTON);
        buttonPanel.add(TWO_BUTTON);
        buttonPanel.add(THREE_BUTTON);
        buttonPanel.add(PLUS_BUTTON);

        buttonPanel.add(FOUR_BUTTON);
        buttonPanel.add(FIVE_BUTTON);
        buttonPanel.add(SIX_BUTTON);
        buttonPanel.add(MINUS_BUTTON);

        buttonPanel.add(SEVEN_BUTTON);
        buttonPanel.add(EIGHT_BUTTON);
        buttonPanel.add(NINE_BUTTON);
        buttonPanel.add(MULTIPLY_BUTTON);

        buttonPanel.add(LEFT_BRACKETS_BUTTON);
        buttonPanel.add(ZERO_BUTTON);
        buttonPanel.add(RIGHT_BRACKETS_BUTTON);
        buttonPanel.add(DIVIDE_BUTTON);

        buttonPanel.add(DOT_BUTTON);
        buttonPanel.add(EQUAL_BUTTON);
        buttonPanel.add(CLEAR_BUTTON);
        buttonPanel.add(OFF_BUTTON);

        contentPanel.add(buttonPanel,BorderLayout.CENTER);

        this.add(contentPanel);

        this.setBounds(50, 50, 450, 450);
        this.setVisible(true);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }

    public JButton getZERO_BUTTON() {
        return ZERO_BUTTON;
    }

    public JButton getONE_BUTTON() {
        return ONE_BUTTON;
    }

    public JButton getTWO_BUTTON() {
        return TWO_BUTTON;
    }

    public JButton getTHREE_BUTTON() {
        return THREE_BUTTON;
    }

    public JButton getFOUR_BUTTON() {
        return FOUR_BUTTON;
    }

    public JButton getFIVE_BUTTON() {
        return FIVE_BUTTON;
    }

    public JButton getSIX_BUTTON() {
        return SIX_BUTTON;
    }

    public JButton getSEVEN_BUTTON() {
        return SEVEN_BUTTON;
    }

    public JButton getEIGHT_BUTTON() {
        return EIGHT_BUTTON;
    }

    public JButton getNINE_BUTTON() {
        return NINE_BUTTON;
    }

    public JButton getLEFT_BRACKETS_BUTTON() {
        return LEFT_BRACKETS_BUTTON;
    }

    public JButton getRIGHT_BRACKETS_BUTTON() {
        return RIGHT_BRACKETS_BUTTON;
    }

    public JButton getPLUS_BUTTON() {
        return PLUS_BUTTON;
    }

    public JButton getMINUS_BUTTON() {
        return MINUS_BUTTON;
    }

    public JButton getMULTIPLY_BUTTON() {
        return MULTIPLY_BUTTON;
    }

    public JButton getDIVIDE_BUTTON() {
        return DIVIDE_BUTTON;
    }

    public JButton getEQUAL_BUTTON() {
        return EQUAL_BUTTON;
    }

    public JButton getCLEAR_BUTTON() {
        return CLEAR_BUTTON;
    }

    public JButton getDOT_BUTTON() {
        return DOT_BUTTON;
    }

    public JButton getOFF_BUTTON() {
        return OFF_BUTTON;
    }

    public JTextField getTEXT_FIELD() {
        return TEXT_FIELD;
    }
}
